import 'package:spendbook/models/model.dart';

class Record extends Model<Record> {
  @override
  String url = '/record';

  double _fee = 0.00;

  String description = '';

  String category = '其他';

  int? cardId;

  Map<String, dynamic>? metadata;

  set fee(dynamic value) {
    _fee = formatDouble(value);
  }

  get fee {
    return _fee;
  }

  @override
  void fromJson(Map<String, dynamic> json) {
    fee = json['fee'];
    description = json['description'];
    category = json['category'];
    metadata = json['metadata'];
    cardId = json['card_id'];
    super.fromJson(json);
  }

  @override
  Map<String, dynamic> toJson() => {'fee': _fee, 'description': description, 'category': category, 'card_id': cardId}..addAll(super.toJson());
}
